<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: red;

        }
    </style>
</head>

<body>
    <button>点击</button>
    <input type="text">
    <script>
        var btn = document.querySelector('button')
        var ip = document.querySelector('input')

        btn.onclick = function () {
            if (ip.type == 'text') {
                ip.type = 'password'
                console.log(ip.type)
            } else {
                ip.type = 'text'
                console.log(ip.type)
                console.log("第二个")
            }
        }
    </script>
    <div>
    </div>
    <script>
        var div = document.querySelector('div')
        div.onclick = function () {
            this.style.backgroundColor = 'yellow';
        }
    </script>
</body>

</html>